Skip to content

feat(view): extend isset to handle multiple conditions#1938

Merged
brendt merged 4 commits intotempestphp:3.xfrom
iamdadmin:3.x-isset-expressions
Feb 12, 2026
Merged

feat(view): extend isset to handle multiple conditions#1938
brendt merged 4 commits intotempestphp:3.xfrom
iamdadmin:3.x-isset-expressions

Conversation

@iamdadmin
Copy link
Contributor

Closes #1937

Updated /packages/view/src/Elements/PhpIfElement.php

     public function compile(): string
     {
         if ($condition = $this->wrappingElement->consumeAttribute(':isset')) {
-            $condition = sprintf('isset(%s)', $condition);
+            $condition = preg_replace('/\$\w+/', 'isset($0)', $condition);

Updated docs and tests, and real-world tested it in an app, both in single-case and multi-case.

Expression logic is untested, because all the function does is wrap isset around a $var, so it remains the responsibility of a developer to produce expressions which evaluate to true or false as needed.

@iamdadmin
Copy link
Contributor Author

This should be ready for workflows to run when someone has a chance! Many thanks.

@brendt
Copy link
Member

brendt commented Feb 12, 2026

I like it. It's a bit out of the box, but that's exactly what Tempest is about. And this feels very intuitive to me.

@brendt
Copy link
Member

brendt commented Feb 12, 2026

Also I appreciate the docs update 💯

Gonna merge this when CI is done

@iamdadmin
Copy link
Contributor Author

Epic thanks!

@brendt brendt merged commit f2342cd into tempestphp:3.x Feb 12, 2026
81 checks passed
@iamdadmin iamdadmin deleted the 3.x-isset-expressions branch February 12, 2026 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend :isset element handling in view to support multiple vars

2 participants